#!/bin/sh

. /lib/lsb/init-functions

PATH=/sbin:/bin:/usr/sbin:/usr/bin
NAME=snmpxmld
DESC="SNMP/XML protocol gate"
DAEMON=/usr/bin/snmpxmld
SNMPXMLDCONF=/etc/snmpxml/conf.xml

PIDFILE=/tmp/snmpxmld.lock

# Exit if the package is not installed
[ -x "$DAEMON" ] || exit 0

snmpxmld_start () {
    log_daemon_msg "Starting $DESC" "$NAME"

    start-stop-daemon --start --quiet --oknodo --pidfile "$PIDFILE" \
        --exec "$DAEMON" -- "$SNMPXMLDCONF"
    log_end_msg $?
}

snmpxmld_stop () {

    log_daemon_msg "Stopping $DESC" "$NAME"
    start-stop-daemon --stop --quiet --oknodo --retry 5 --pidfile "$PIDFILE" \
        --exec $DAEMON
    log_end_msg $?
}

case "$1" in
    start)
        snmpxmld_start
        ;;
    stop)
        snmpxmld_stop
        ;;
    restart|reload)
        snmpxmld_stop
        snmpxmld_start
        ;;
    *)
        echo "Usage: $0 {start|stop|restart|reload}"
        exit 2
        ;;
esac
